home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 013 / move13.arc / DOS.MAC < prev    next >
Encoding:
Text File  |  1986-04-12  |  3.9 KB  |  173 lines

  1. .xlist            ; hide this entire file from .LST file
  2. .xcref            ; hide the symbols from .LST & .REF files
  3. ; a number of generic DOS 2.0 functions
  4. .xcref close
  5. ; close
  6. ;  macro to close file
  7. ;  input  
  8. ;    handle    -  the file handle to close
  9. close    macro handle
  10.     mov ah,3eh
  11.     mov bx,handle
  12.     int 21h
  13. endm
  14. .xcref delete
  15. ; delete
  16. ;  macro to delete file
  17. ;  input
  18. ;    which    -  asciiz string of file to delete
  19. delete    macro which
  20.     mov ah,41h
  21.     lea dx,which
  22.     int 21h
  23. endm
  24. .xcref lseek
  25. ; lseek
  26. ;  macro to move file ptr
  27. ;  input
  28. ;    handle    - handle of file
  29. ;    offs    - immediate offset ot move file pointer
  30. ;    mode    - how to move the file pointer
  31. lseek    macro handle,offs,mode
  32.     mov ah,42h
  33.     mov al,mode
  34.     mov bx,handle
  35.     mov cx,offs / 0ffffh
  36.     mov dx,offs mod 0ffffh
  37.     int 21h
  38. endm
  39. .xcref open
  40. ; open
  41. ;  macro to open a file
  42. ;  input
  43. ;    fname    - asciiz string of file to open
  44. ;    mode    - the mode to open file for
  45. open    macro fname,mode
  46.     mov ah,3dh
  47.     mov al,mode
  48.     lea dx,fname
  49.     int 21h
  50. endm
  51. .xcref read
  52. ; read
  53. ;  macro to read from a file
  54. ;  input
  55. ;    handle    - handle of file to read
  56. ;    buffer    - where to put stuff read
  57. ;    len    - number of bytes to read
  58. read    macro handle,buffer,len
  59.     mov ah,3fh
  60.     mov bx,handle
  61.     mov cx,len
  62.     lea dx,buffer
  63.     int 21h
  64. endm
  65. .xcref write
  66. ; write
  67. ;  macro to write to a file
  68. ;  input
  69. ;    handle    - handle of file to write
  70. ;    buffer    - where to put stuff write
  71. ;    len    - number of bytes to write
  72. write    macro handle,buffer,len
  73.     mov ah,40h
  74.     mov bx,handle
  75.     mov cx,len
  76.     lea dx,buffer
  77.     int 21h
  78. endm
  79. .xcref setvector
  80. ; setvector
  81. ;  macro to set interrupt vector
  82. ;  input
  83. ;    which    - the interrupt vector number to set
  84. ;    where    - the location to set to (assumed to be in DS)
  85. setvector macro which,where
  86.     mov ah,25h
  87.     mov al,which
  88.     lea dx,where
  89.     int 21h
  90. endm
  91. .xcref print
  92. ; print
  93. ;  macro to print out a '$' terminated string
  94. ;  input
  95. ;    what    - the string to print out
  96. print    macro what
  97.     lea dx,what
  98.     mov ah,9
  99.     int 21h
  100. endm
  101. .xcref resident_exit
  102. ; resident_exit
  103. ;  macro to terminate a process w/ stay resident
  104. ;  input
  105. ;    where    - the end of the what need to be preserved
  106. resident_exit macro where
  107.     mov ah,31h
  108.     lea dx,where
  109.     int 21h
  110. endm
  111. .xcref exit
  112. ; exit
  113. ;  macro to terminate a process w/ error code
  114. ;  input
  115. ;    code    - the error code to return
  116. exit    macro code
  117.     mov al,code
  118.     mov ah,4ch
  119.     int 21h
  120. endm
  121. .xcref putchar
  122. ; putchar
  123. ;  macro to print one char to stdout
  124. ;  input
  125. ;    char    - the character to print
  126. putchar    macro char
  127.     mov dl,char
  128.     mov ah,2
  129.     int 21h
  130. endm
  131. .xcref setdta
  132. ; setdta
  133. ;  macro to set the dta address
  134. ;  input
  135. ;    where    - the address of the new dta
  136. setdta    macro where
  137.     lea dx,where
  138.     mov ah,1ah
  139.     int 21h
  140. endm
  141. .xcref dta_type,dta_reserved,dta_attr,dta_time,dta_date,dta_size,dta_name
  142. ; define dta after a dir search for MS-DOS 2.11
  143. dta_type struc
  144.     dta_?attr    db 1 dup(?)    ; the attribute you were looking for
  145.     dta_?drive    db 1 dup(?)    ; the drive you were looking on
  146.     dta_?name    db 11 dup(?)    ; the file name you were looking for
  147.     dta_reserved db 8 dup(?)    ; I assume sectors where file was found
  148.     dta_attr    db 1 dup(?)    ; the attribute of file found
  149.     dta_time    dw 1 dup(?)    ; the time of file found
  150.     dta_date    dw 1 dup(?)    ; the date of file found
  151.     dta_size    dd 1 dup(?)    ; the size of file found
  152.     dta_name    db 13 dup(?)    ; the name of file found
  153. dta_type ends
  154. .xcref is_normal,is_read_only,is_hidden,is_system,is_label,is_dir,is_archive
  155. ; define directory entry attributes
  156. is_normal    equ 00h        ; bit map for normal files
  157. is_read_only    equ 01h        ; bit map for read only files
  158. is_hidden    equ 02h        ; bit map for hidden files
  159. is_system    equ 04h        ; bit map for system files
  160. is_label    equ 08h        ; bit map for labels
  161. is_dir        equ 10h        ; bit map for directories
  162. is_archive    equ 20h        ; bit map for none archived files
  163. ; define the standard devices
  164. .xcref stdin,stdout,stderr,aux,prn
  165. ; define the standard handles available in DOS
  166. stdin    equ 0
  167. stdout    equ 1
  168. stderr    equ 2
  169. aux    equ 3
  170. prn    equ 4
  171. .cref
  172. .list
  173.